package com.example.travel.controller;

import com.example.travel.entity.Hotel;
import com.example.travel.entity.Orderform;
import com.example.travel.entity.bo.OrderformBO;
import com.example.travel.entity.dto.HotelDTO;
import com.example.travel.entity.dto.UserDTO;
import com.example.travel.service.IHotelService;
import com.example.travel.util.ResultUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("HotelController")
public class HotelController {


    @Autowired
    private IHotelService hotelService;

    /**
     * 用户查询酒店信息
     * @param hotelDTO
     * @return
     */
    @GetMapping("/queryHotelInfo")
    public PageInfo<Hotel> queryHotelInfo(HotelDTO hotelDTO){
        return hotelService.queryHotelInfo(hotelDTO);
    }

    /**
     * 用户预订酒店
     * @param orderform
     * @return
     */
    @PostMapping("/userBookHotel")
    public boolean userBookHotel(Orderform orderform){
        return hotelService.userBookHotel(orderform);
    }


    /**
     * 用户查询酒店订单信息
     * @param userDTO
     * @return
     */
    @GetMapping("/queryOrderForm")
    public ResultUtil queryOrderForm(UserDTO userDTO){
        PageInfo<OrderformBO> userPageInfo = hotelService.queryOrderForm(userDTO);
        return ResultUtil.ok(userPageInfo);
    }




}
